perm filename EADD6.2[EAL,HE]1 blob sn#674841 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor: aux routines for addStmnt }
C00005 00003	procedure add1Filler(nextLinep: cursorpp var l: integer 
C00009 ENDMK
C⊗;
{$NOMAIN	Editor: aux routines for addStmnt }

%include eedit.hdr;

{ Externally defined routines from elsewhere: }

	(* From PAUX1 *)
function checkArg(n: nodep; d: datatypes): nodep;		external;

	(* From PAUX2 *)
function evalOrder(what,last: nodep; pcons: boolean): nodep;	external;

	(* From EPUT *)
procedure putLine;						external;

	(* From EAUX2C *)
procedure deleteLines(start,number,coff: integer);		external;

	(* From EPUTST *)
procedure putstmnt(s: statementp; indent, plevel: integer);	external;

	(* From EEXPAR *)
function eExprParse: nodep;					external;

	(* From EPAR3E *)
procedure eMClauseParse(n: nodep);				external;

	(* From EAUX3C - addStmnt aux routines *)
function getEmptyStmnt(sp:statementp): statementp;		external;
procedure addNSt(sty: stmntypes; nextLinep: cursorpp; 
	var sp: statementp; slabel: varidefp; 
	emptyp,stok: boolean; var nogood: boolean);		external;
function addNode(nextLinep: cursorpp; slabel:varidefp): nodep;	external;

	(* From PP *)
procedure relLine(l: linerecp);					external;
procedure ppLine; 						external;
procedure ppOutNow; 						external;
procedure ppChar(ch: ascii); 					external;
procedure pp5(ch: c5str; length: integer); 			external;
procedure pp10(ch: cstring; length: integer); 			external;
procedure pp10L(ch: cstring; length: integer);			external;
procedure pp20(ch: c20str; length: integer); 			external;
procedure pp20L(ch: c20str; length: integer); 			external;

procedure add1Filler(nextLinep: cursorpp; var l: integer; 
	var emptyp,stok,clok,nogood: boolean; 
	var sp: statementp; slabel: varidefp); external;
procedure add1Filler;
 var np: nodep;
 begin
 with eCurToken do
  if (filler = untltype) and (fieldNum = 2) and
	  nextLinep↑.stmntp and (nextLinep↑.st↑.stype = untiltype) then
    with nextLinep↑.st↑ do
     begin					(* this is special *)
     cond := checkArg(eExprParse,svaltype);
     exprs := evalOrder(cond,nil,true);
     if not emptyp then
       deleteLines(ocur,1,1);		(* flush the extra line *)
     l := cursorLine - topDline + 1;	(* offset into line array *)
     relLine(lines[l]);			(* release old line *)
     lines[l] := nil;
     end
   else if (filler = dotype) or (filler = untltype) then
    begin
    addNSt(untiltype,nextLinep,sp,slabel,emptyp,stok,nogood);
    if stOk then
      with sp↑ do
       begin
       if filler = untltype then
	 begin
	 cond := checkArg(eExprParse,svaltype);
	 exprs := evalOrder(cond,nil,true);
	 cursorLine := cursorLine + 2;
	 end
	else cond := nil;
       nlines := nlines + 2;
       body := getEmptyStmnt(sp);
       end
    end
   else if (filler = totype) or (filler = viatype) or (filler = withtype) then
    begin
    if clOk then
      begin				(* add a new motion clause *)
      np := addNode(nextLinep,slabel);
      with np↑ do
       if filler = totype then
	 begin ntype := destnode; loc := nil; code := nil end
	else if filler = viatype then
	 begin ntype := viaptnode; vlist := false; via := nil; duration := nil;
	       velocity := nil; vcode := nil end
	else ntype := nullingnode;	(* random choice *)
      eMClauseParse(np);
      with cursorStack[cursor-1] do
       if (filler = totype) and (st↑.clauses = np) then
	 begin			(* clause should go on previous line *)
	 l := cline - topDline + 1;
	 if l > 0 then 			(* if any *)
	   begin
	   relLine(lines[l]);
	   lines[l] := nil;
	   firstLine := cline;
	   lastLine := cline;
	   curLine := 0;
	   putStmnt(dprog,0,99);	(* re-display old line *)
	   putLine;
	   end;
	 st↑.nlines := st↑.nlines - 1;
	 cursor := cursor - 1;
	 nogood := true;		(* flush extra line *)
	 end;
      end
     else
      begin
      pp20L(' Can''t have a clause',20); pp5(' here',5); ppLine;
      nogood := true;
      end;
    end
 end;